﻿/// <reference path="../scripts/prototype.js"/>
/// <reference path="MicrosoftAjax.js"/>

// JScript File
var pc = new Array();
var pcCount=0;

function regCheckbox(checkboxID)
{
    pc[pcCount] = document.getElementById(checkboxID);
    pcCount++;
}

function onAction(action)
{
    if (action == "delete")
    {
        deleteProducts();
    }
    
    document.getElementById('ddlAction').selectedIndex=0;
}

function deleteProducts()
{
    var productIDs = new Array();
    for(var i=0; i<pcCount; i++)
    {
        if (pc[i].checked)
        {
            productIDs[productIDs.length] = pc[i].value;
        }
    }
    
    if (productIDs.length > 0)
        TanashCMS.Services.inventory.deleteProducts(productIDs, onDeleteSuccess, onDeleteFail);
}
function onDeleteSuccess()
{
    document.location.href = document.location.href;
}
function onDeleteFail(error)
{
    alert(error._message);
}

function onSelectAll()
{
    for(var i=0; i<pcCount; i++)
        pc[i].checked = true;
}

function onSelectNone()
{
    for(var i=0; i<pcCount; i++)
        pc[i].checked = false;
}

function save(param)
{
    alert(param);
    
}

var selectedImage='';
var ctrlImage=null;
var litImage=null;
function onSelectImage(returnVal) {
  ctrlImage.src="/services/thumbnail.aspx?method=restricttosize&sx=400&i="+selectedImage;
  litImage.value = selectedImage;
}

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();